package org.zzz.hepotaiya.report;

import java.util.List;
import java.util.Map;

import org.zzz.hepotaiya.beans.BatchInfo;
import org.zzz.hepotaiya.container.ContainerImpl;
import org.zzz.hepotaiya.container.IContainer;
import org.zzz.hepotaiya.loader.BatchLoader;
import org.zzz.hepotaiya.loader.BatchLoaderImpl;
import org.zzz.hepotaiya.report.writer.ReportWriter;

public class AnnotationMappingReport {
	IContainer container = new ContainerImpl();
	BatchLoader loader = new BatchLoaderImpl();
	ReportWriter writer;
	
	public void setContainer(IContainer container){
		this.container = container;
	}
	public void setBatchLoader(BatchLoader batchLoader) {
		this.loader = batchLoader;
	}
	public void setReportWriter(ReportWriter reportWriter) {
		this.writer = reportWriter;
	}

	public void doReport(String batchRootPackage) throws Exception {
		loader.setContainer(container);
		Map<Integer, List<BatchInfo>> map = loader.load(batchRootPackage, null);
		for (int i = 0; i < map.size(); i++) {
			if (null == map.get(i)) {
				continue;
			}
			List<BatchInfo> list = map.get(i);
			for (BatchInfo info : list) {
				writer.write(info);
			}
		}
	}
}
